package 笔记.设计模式.建造者模式;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chenhailong
 * @ClassName: Build
 * @Description: TODO
 * @date 2021/7/6 16:13
 * @Version 1.0
 */
public class Build {


    private List<Item> items = new ArrayList<>();
//    private Item item;

    public void addItem(Item item) {
        items.add(item);
    }

    public float price() {
        float a = 0.0f;
        for (int i = 0; i < items.size(); i++) {
            a += items.get(i).price() ; // 食品价格
            a += items.get(i).packing().price(); // 包装价格
        }
        return a;
    }

    public void getItem() {
        for (int i = 0; i < items.size(); i++) {
            System.out.print(" 名字为:" + items.get(i).name());
            System.out.print(", 价格为:" + items.get(i).price());
            System.out.print(", 包装名字为:" + items.get(i).packing().name());
            System.out.println(", 包装价格为:" + items.get(i).packing().price());
        }
    }
}
